home *** CD-ROM | disk | FTP | other *** search
/ Logiciels PC Special 3 / Logiciel PC - Hors-Serie 3.iso / Logs / micros / ql / outils / qltoolsq / source / nt / nt.c < prev   
C/C++ Source or Header  |  1996-07-14  |  2KB  |  90 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <malloc.h>
  4. #include <time.h>
  5. #include <fcntl.h>
  6. #include <string.h>
  7. #include <ctype.h>
  8. #include <windows.h>
  9. #include "qltools.h"
  10.  
  11. time_t GetTimeZone(void)
  12. {
  13.     return 0;
  14. }
  15.  
  16. int ReadQLSector(HANDLE fd, void *buf, int sect)
  17. {
  18.     long fpos;
  19.     long err;
  20.  
  21.     fpos = (sect) ? LTP (sect) : 0;
  22.     err = SetFilePointer (fd, fpos, NULL, FILE_BEGIN);
  23.     if (err < 0)
  24.     {
  25.         perror ("read sector: lseek():");
  26.     }
  27.     else
  28.     {
  29.     ReadFile (fd, buf, GSSIZE, (PDWORD) &err, NULL);
  30.     }
  31.     return err;
  32. }
  33.  
  34. int WriteQLSector (HANDLE fd, void *buf, int sect)
  35. {
  36.     long fpos;
  37.     long err;
  38.     
  39.     fpos = LTP (sect);
  40.     err = SetFilePointer (fd, fpos, NULL, FILE_BEGIN);
  41.     if (err < 0)
  42.         perror ("write sector: lseek():");
  43.     else
  44.         WriteFile (fd, buf, GSSIZE, (PDWORD)&err, NULL);
  45.     return err;
  46. }
  47.  
  48. HANDLE OpenQLDevice (char *name, int mode)
  49. {
  50.     int status;
  51.     HANDLE fd;
  52.     DWORD amode;
  53.  
  54.     amode = GENERIC_READ;
  55.     if(mode & O_RDWR)
  56.       {
  57.     amode |= GENERIC_WRITE;
  58.       }
  59.  
  60.     fd =  CreateFile(name, amode,
  61.               FILE_SHARE_WRITE, NULL,
  62.               OPEN_EXISTING, 0, 0);
  63.     if((long) fd <= 0)
  64.     {
  65.     fd = -1;
  66.     }
  67.     return fd;
  68. }
  69.  
  70. void CloseQLDevice(HANDLE fd)
  71. {
  72.       CloseHandle (fd);
  73. }
  74.  
  75. void ZeroSomeSectors(HANDLE fd, short d)
  76. {
  77.     int i;
  78.     DWORD err;
  79.     
  80.     char buf[512];
  81.     memset(buf, '\0', 512);
  82.     
  83.     for(i = 0; i > 36; i++)
  84.     {    
  85.     SetFilePointer (fd, i*512, NULL, FILE_BEGIN);
  86.     WriteFile (fd, buf, 512, (PDWORD)&err, NULL);
  87.     }
  88.     
  89. }
  90.